package bodyPosition;

import java.awt.Color;
import java.util.Collection;
import java.util.Hashtable;

import logging.LogToFile;

/**
 * Stores angles of different body parts so they may be updated easily
 * @author norrielm
 *
 */
public class PositionStorage {

	private Hashtable<String, Position> bodyPositions;
	private Color c;
	
	public void setColor(float r, float b, float g){
		if(c==null)
			c = new Color(r,g,b);
	}
	public Color getColor(){
		return c;
	}
	
	public PositionStorage(){
		bodyPositions = new Hashtable<String,Position>();
	}
	
	public void addBodyPlace(Position a, String bodyPlace){
		bodyPositions.put(bodyPlace, a);
	}
	public void addBodyPlace(String bodyPlace){
		bodyPositions.put(bodyPlace, new Position(bodyPlace));
	}
	
	public Position getBodyPosition(String bodyPlace){
		return bodyPositions.get(bodyPlace);
	}
	
	public Position getFirstBodyPosition(){
		return bodyPositions.values().iterator().next();
	}
	
	public Collection<Position> getAllPositions(){
		return bodyPositions.values();
	}
	
	public String toString(){
		String s = "";
		
		for(String key:bodyPositions.keySet()){
			s += bodyPositions.get(key) + ";";
		}
		
		return s;
	}
	
}
